package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.LotMtlRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.OMtlWatiUpRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.OMtlwaitAddRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.SurpDetailRequest;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcOtherMtlInService;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcSurplusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-剩料转入作业")
@RoleCheck(prgIds = {"160111"})
public class PcSurplusController {
    @Autowired
    private IPcSurplusService service;
    @Autowired
    IPcOtherMtlInService mtlService;

    @GetMapping("/getSurpTempQuery")
    @ApiOperation(value = "剩料转入作业-待入剩料仓明细-查询", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo getSurpTempQuery() {
        return service.getSurpTempQuery();
    }

    @PutMapping("/surpTempAdd")
    @ApiOperation(value = "剩料转入作业-转入待入剩料仓-新增", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpTempAdd(@RequestBody List<OMtlwaitAddRequest> request) {
        return service.surpTempAdd(request);
    }

    @PutMapping("/surpTempUpdate")
    @ApiOperation(value = "剩料转入作业-待入剩料修改-更新", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpTempUpdate(@RequestBody List<OMtlWatiUpRequest> request) {
        return service.surpTempUpdate(request);
    }

    @PostMapping("/surpTempDelete")
    @ApiOperation(value = "剩料转入作业-待入剩料仓删除-删除", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpTempDelete(@RequestParam@ApiParam("物料号") String mtlNo) {
        return service.surpTempDelete(mtlNo);
    }

    @PutMapping("/surpLotMtlQuery")
    @ApiOperation(value = "剩料转入作业-指令材料查询-分页可条件查询", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpLotMtlQuery(@RequestBody LotMtlRequest request) {
        return service.getLotMtlQuery(request, 0);
    }

    @PutMapping("/getSurpDetailQuery")
    @ApiOperation(value = "剩料转入作业-剩料仓材料明细查询-可条件查询", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo getSurpDetailQuery(@RequestBody SurpDetailRequest request) {
        return service.getSurpDetailQuery(request);
    }

    @PostMapping("/surpDetailAdd")
    @ApiOperation(value = "剩料转入作业-出库批处理-新增", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpDetailAdd(@RequestParam@ApiParam("物料编号") String mtlNo,
                                      @RequestParam@ApiParam("入库原因") String slipReason) {
        return service.surpDetailAdd(mtlNo,slipReason);
    }

    @PostMapping("/surpDetailDelete")
    @ApiOperation(value = "剩料转入作业-剩料仓材料删除-删除", tags = "仓储部-仓储工厂作业-剩料转入作业")
    public ResponseInfo surpDetailDelete(@RequestParam@ApiParam("物料号") String mtlNo,
                                         @RequestParam@ApiParam("单据号码") String slipNo) {
        return service.surpDetailDelete(mtlNo,slipNo);
    }
}
